<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>history</title>
    <script>
        document.addEventListener("DOMContentLoaded", () => {
            const btn = document.getElementsByClassName("btn")[0]
            btn.onclick = () => {
                console.log(history)
                console.log("----",history.length)

                // history.back()       相当于浏览器后退按钮
                // history.forward()    相当于浏览器前进按钮
                // history.go()         参数为正值，向前跳转，参数为负值，向后跳转，且可以指定跳转的数量。
            }
        })
    </script>

</head>

<body>
    <button class="btn">按钮</button>
</body>

</html>